package com.nantong.common.core.enums.commonEnums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 权限类型枚举
 *
 * @author nantong
 */
@Getter
@AllArgsConstructor
public enum PermissionTypeEnum {

    /**
     * 目录
     */
    MENU(1, "目录"),

    /**
     * 菜单
     */
    MENU_ITEM(2, "菜单"),

    /**
     * 按钮
     */
    BUTTON(3, "按钮");

    private final Integer code;
    private final String desc;

    /**
     * 根据code获取枚举
     *
     * @param code 类型码
     * @return 权限类型枚举
     */
    public static PermissionTypeEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (PermissionTypeEnum value : PermissionTypeEnum.values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }
}
